package org.shilong.logic.Json;

import java.util.Iterator;
import java.util.List;

import org.shilong.model.PartyModel;

import com.url.ajax.json.JSONArray;
import com.url.ajax.json.JSONException;
import com.url.ajax.json.JSONObject;

public class QueryMyParty4JsonLogic {

	private static List<PartyModel> mList = null;

	private static String rlt = null;

	private static JSONObject jObject = null;

	private static JSONArray jArray = null;

	private static Iterator<PartyModel> it = null;

	public static String getRlt( Object o_bject ){

		mList = null;

		rlt = null;

		mList = ( List<PartyModel> )o_bject;

		it = mList.iterator();

		jObject = new JSONObject();

		jArray = new JSONArray();

		while (it.hasNext()) {
			PartyModel partyModel = it.next();

			JSONObject obj = new JSONObject();

			try {
				obj.put("pa_id", partyModel.getPa_seq_id()+"");
				obj.put( "pa_cj_value", partyModel.getPa_cj_value() );
				obj.put( "pa_comment",  partyModel.getPa_comment() ); 
				obj.put( "pa_end_time",  partyModel.getPa_end_time() ); 
				obj.put( "pa_people",  partyModel.getPa_people() ); 
				obj.put( "pa_start_time",  partyModel.getPa_start_time() ); 
				obj.put( "pa_title",  partyModel.getPa_title() ); 

				jArray.put( obj );
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 


		}

		try {
			jObject.put( "rlt", jArray );
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		rlt = jObject.toString();

		return rlt;
	}
	
}
